From: Timo Tijhof Date: Tue, 3 Nov 2015 06:36:06 +0000 (+0000) Subject: objectcache: Add TTL_INDEFINITE to IExpiringStore X-Git-Tag: 1.31.0-rc.0~9132^2 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=03b281d55bbafd5746db580676beed9c262261b6;p=lhc%2Fweb%2Fwiklou.git objectcache: Add TTL_INDEFINITE to IExpiringStore Especially useful when interacting with getWithSetCallback of HashBagOStuff where a $exptime is required before the callback. In set() it is typically left out and thus not as counter-intuitive. Change-Id: Ic2f7adda3c00cefe701d77bea91a7e8e77ef1439 --- diff --git a/includes/libs/objectcache/HashBagOStuff.php b/includes/libs/objectcache/HashBagOStuff.php index bdcf18017f..432d040cd6 100644 --- a/includes/libs/objectcache/HashBagOStuff.php +++ b/includes/libs/objectcache/HashBagOStuff.php @@ -50,7 +50,7 @@ class HashBagOStuff extends BagOStuff { protected function expire( $key ) { $et = $this->bag[$key][self::KEY_EXP]; - if ( $et == 0 || $et > time() ) { + if ( $et == self::TTL_INDEFINITE || $et > time() ) { return false; } diff --git a/includes/libs/objectcache/IExpiringStore.php b/includes/libs/objectcache/IExpiringStore.php index b5ad702a53..fa465c7d35 100644 --- a/includes/libs/objectcache/IExpiringStore.php +++ b/includes/libs/objectcache/IExpiringStore.php @@ -37,4 +37,6 @@ interface IExpiringStore { const TTL_WEEK = 604800; // 7 * 24 * 3600 const TTL_MONTH = 2592000; // 30 * 24 * 3600 const TTL_YEAR = 31536000; // 365 * 24 * 3600 + + const TTL_INDEFINITE = 0; } diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index c04d4b6be4..7e3fa4fd47 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -95,8 +95,6 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { /** Default time-since-expiry on a miss that makes a key "hot" */ const LOCK_TSE = 1; - /** Idiom for set()/getWithSetCallback() TTL being "forever" */ - const TTL_INDEFINITE = 0; /** Idiom for getWithSetCallback() callbacks to avoid calling set() */ const TTL_UNCACHEABLE = -1; /** Idiom for getWithSetCallback() callbacks to 'lockTSE' logic */